package com.ymatou.query.seller.trading.api.testcase;

import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.seller.trading.api.service.GetUserAccountInfoCall_seller;
import com.ymatou.query.trading.api.parameter.GetUserAccountInfoBean;
import com.ymatou.query.trading.api.service.GetUserAccountInfoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.utils.constant.ECode;

/**
 * 获取用户账户信息 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetUserAccountInfo {

	private static GetUserAccountInfoBean useraccountinfobean;
	private static GetUserAccountInfoCall useraccountinfocall;
	private static GetUserAccountInfoCall_seller useraccountinfocall_seller;;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取用户账户信息");
	}

	@Before
	public void caseUp() {

		useraccountinfobean = new GetUserAccountInfoBean();
		useraccountinfocall_seller = new GetUserAccountInfoCall_seller();
		useraccountinfocall = new GetUserAccountInfoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(useraccountinfocall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetUserAccountInfo_001() {
		Logger.start(true,"获取用户账户信息成功");
		try {
			// 参数
			int BuyerId = 1113;
			useraccountinfobean.setBuyerId(BuyerId);
			// seller 后台发送请求
			useraccountinfocall_seller.setData(useraccountinfobean);
			useraccountinfocall_seller.callService();
			Logger.comment("useraccountinfocall_seller send:" + useraccountinfocall_seller.getEntityString());
			Logger.comment("useraccountinfocall_seller response:" + useraccountinfocall_seller.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, useraccountinfocall_seller.getCode(), "验证Code");

			// user 后台发送请求
			useraccountinfocall.setData(useraccountinfobean);
			useraccountinfocall.callService();
			Logger.comment("useraccountinfocall send:" + useraccountinfocall.getEntityString());
			Logger.comment("useraccountinfocall response:" + useraccountinfocall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, useraccountinfocall.getCode(), "验证Code");
			Logger.verifyEquals(useraccountinfocall_seller.getData().toString(), useraccountinfocall.getData()
					.toString(), "验证商家后台的请求的返回的data数据跟用户请求返回的data数据一致");

			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// useraccountinfocall.getMsg(), "验证Msg");
			/*
			 * Logger.verifyEquals(true, useraccountinfocall.getAccountAmount()
			 * > 0, "验证账户余额"); Logger.verifyEquals(true,
			 * useraccountinfocall.getGiftAmount() >= 0, "验证红包余额");
			 * Logger.verifyEquals(true,
			 * useraccountinfocall.getExistsTradingPwd(), "验证已设置交易密码");
			 */
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetUserAccountInfo_002() {
		Logger.start(true,"用户id为空");
		try {
			// 参数
			int BuyerId = 1113;
			// useraccountinfobean.setBuyerId(BuyerId);
			// seller 后台发送请求
			useraccountinfocall_seller.setData(useraccountinfobean);
			useraccountinfocall_seller.callService();
			Logger.comment("useraccountinfocall_seller send:" + useraccountinfocall_seller.getEntityString());
			Logger.comment("useraccountinfocall_seller response:" + useraccountinfocall_seller.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, useraccountinfocall_seller.getCode(), "验证Code");

			// user 后台发送请求
			useraccountinfocall.setData(useraccountinfobean);
			useraccountinfocall.callService();
			Logger.comment("useraccountinfocall send:" + useraccountinfocall.getEntityString());
			Logger.comment("useraccountinfocall response:" + useraccountinfocall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, useraccountinfocall.getCode(), "验证Code");
			Logger.verifyEquals(useraccountinfocall_seller.getData().toString(), useraccountinfocall.getData()
					.toString(), "验证商家后台的请求的返回的data数据跟用户请求返回的data数据一致");

			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// useraccountinfocall.getMsg(), "验证Msg");
			/*
			 * Logger.verifyEquals(true, useraccountinfocall.getAccountAmount()
			 * == 0, "验证账户余额"); Logger.verifyEquals(true,
			 * useraccountinfocall.getGiftAmount() == 0, "验证红包余额");
			 * Logger.verifyEquals(false,
			 * useraccountinfocall.getExistsTradingPwd(), "验证已设置交易密码");
			 */
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetUserAccountInfo_003() {
		Logger.start(true,"用户账户信息不存在");
		try {
			// 参数
			Map user = new OrderCallService().registerUser();
			int BuyerId = (Integer) user.get("userId");
			useraccountinfobean.setBuyerId(BuyerId);
			// seller 后台发送请求
			useraccountinfocall_seller.setData(useraccountinfobean);
			useraccountinfocall_seller.callService();
			Logger.comment("useraccountinfocall_seller send:" + useraccountinfocall_seller.getEntityString());
			Logger.comment("useraccountinfocall_seller response:" + useraccountinfocall_seller.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, useraccountinfocall_seller.getCode(), "验证Code");

			// user 后台发送请求
			useraccountinfocall.setData(useraccountinfobean);
			useraccountinfocall.callService();
			Logger.comment("useraccountinfocall send:" + useraccountinfocall.getEntityString());
			Logger.comment("useraccountinfocall response:" + useraccountinfocall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, useraccountinfocall.getCode(), "验证Code");
			Logger.verifyEquals(useraccountinfocall_seller.getData().toString(), useraccountinfocall.getData()
					.toString(), "验证商家后台的请求的返回的data数据跟用户请求返回的data数据一致");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}